package com.jt.mapper;

import com.jt.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper//Spring为接口创建了一个代理对象
public interface UserMapper {
    List<User> findAll();

    @Select("select id,name,age,sex from demo_user where id = #{id}")
    User findUserById(int id);

    @Insert("insert into demo_user(id,name,age,sex) value(null,#{name},#{age},#{sex})")
//新增时使用
    void insert(User user);
@Update("update demo_user set age=#{age},sex=#{sex} where name=#{name}")
    void updateByName(User user);
@Delete("delete from demo_user where name=#{name}")
    void deleteByName(User user);
}
